package junit;

import java.util.ArrayList;

import java.util.Iterator;
import java.util.List;

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.junit.Test;

import com.tentcoo.entity.TeacherEntity;
import com.tentcoo.service.TeacherService;

@RunWith(SpringJUnit4ClassRunner.class)  
//加载spring配置文件  
@ContextConfiguration(locations={"classpath:config/hibernate.xml"})  
public class TeacherJunit {
	
	@Autowired
	private TeacherService teacherService;
	
	@Test
	public void testSave(){
		TeacherEntity teacherEntity = new TeacherEntity();
		teacherEntity.setName("dsa");
		teacherEntity.setNo("100001");
		teacherEntity.setPhone("10010");
		teacherEntity.setClazz("class1");
		if(teacherService.addTeacher(teacherEntity)){
			System.out.println("添加成功");
		}
	}
	
	@Test
	public void testFind(){
		if(teacherService.findTeacher("100001")==null){
			System.out.println("没有该用户存在");
		}
		else{
			System.out.println(teacherService.findTeacher("100001").toString());
		}
	}
	
	/*@Test
	public void testUpdate(){
		TeacherEntity teacherEntity = new TeacherEntity();
		teacherEntity.setName("dsa");
		teacherEntity.setNo("100001");
		teacherEntity.setPhone("11111");
		teacherEntity.setClazz("软件");
		if(teacherService.updateTeacher(teacherEntity)){
			System.out.println("修改成功");
		}
	}
	
	@Test
	public void testDel(){
		if(teacherService.delTeacher("100001")){
			System.out.println("删除成功");
		}
	}*/
}
